import type {baseResponse, listResponse, optionsType, paramsType} from "@/api/index";
import {useAxios} from "@/api/index";

export interface aiRoleType {
    "id": number
    "createdAt": string
    "title": string
    "avatar": string
    "userID": number
    "category": string
    "abstract": string
    "prompt": string
    "isSquare": boolean
    "isSystem": boolean
    "isReview": boolean
    "sessionCount": number
    "chatCount": number
    "roleUserNickname": string
}

export function aiRoleListApi(params?: paramsType): Promise<baseResponse<listResponse<aiRoleType>>> {
    return useAxios.get("/api/ai_role", {params})
}

export interface aiRoleCreateType {
    title: string
    avatar: string
    category: string
    abstract: string
    prompt: string
}

export function aiRoleCreateApi(data: aiRoleCreateType): Promise<baseResponse<string>> {
    return useAxios.post("/api/ai_role", data)
}

export function aiRoleRemoveApi(id: number): Promise<baseResponse<string>> {
    return useAxios.delete("/api/ai_role/" + id.toString())
}

export function aiRoleAvatarOptions(): Promise<baseResponse<optionsType[]>> {
    return useAxios.get("/api/ai_role/options/avatar_or_category", {params: {type: 1}})
}
export function aiRoleCategoryOptions(): Promise<baseResponse<optionsType[]>> {
    return useAxios.get("/api/ai_role/options/avatar_or_category", {params: {type: 2}})
}

export interface aiRoleUpdateAdminType extends aiRoleCreateType{
    roleID: number
}

export interface aiRoleUpdateUserType extends aiRoleUpdateAdminType{
    isSquare?: boolean
    reason?: string // 更新理由
}
export function aiRoleUpdateAdminApi(data: aiRoleUpdateAdminType):Promise<baseResponse<string>>{
    return useAxios.put("/api/ai_role/admin", data)
}

export function aiRoleUpdateUserApi(data: aiRoleUpdateUserType):Promise<baseResponse<string>>{
    return useAxios.put("/api/ai_role", data)
}


export interface aiRoleOrderCreateType {
    "roleID": number
    "reason": string
    "type": number // 1 推荐 3 删除
}
export function aiRoleOrderCreateApi(data: aiRoleOrderCreateType):Promise<baseResponse<string>>{
    return useAxios.post("/api/ai_role/work_order", data)
}


export function sessionIDByRoleID(roleID: number):Promise<baseResponse<number>>{
    return useAxios.get("/api/ai_role/recent_session", {params: {id: roleID}})
}

